﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Derbster.Domain.Test
{
    [TestClass]
    public class OfficialUnitTest : ContractUnitTest
    {
        [TestMethod]
        public void TestCreateBlank()
        {
            var official = new Official();
            Assert.IsNotNull(official);
        }

        [TestMethod]
        public void TestCreateNameOnly()
        {
            var official = new Official("Test Name");
            Assert.IsNotNull(official);
        }

        [TestMethod]
        public void TestEquals()
        {
            var newOfficial = new Official();
            Assert.IsTrue(newOfficial.Equals(newOfficial));
        }

        [TestMethod]
        public void TestCreateBadNameOnly()
        {
            bool throws = false;
            try
            {
                var official = new Official("  ");
            }
            catch (Exception)
            {
                throws = true;
            }
            Assert.IsTrue(throws);
        }
        [TestMethod]
        public void TestCreateAndVerify()
        {
            var official = new Official("Test Official", "12AB");
            Assert.IsNotNull(official);
            Assert.AreEqual("Test Official", official.Name);
            Assert.AreEqual("12AB", official.Number);
        }

        [TestMethod]
        public void TestCreateBadName()
        {
            bool throws = false;
            try
            {
                var official = new Official("  ", "12AB");
            }
            catch (Exception)
            {
                throws = true;
            }
            Assert.IsTrue(throws);
        }

        [TestMethod]
        public void TestCreateBadNumber()
        {
            bool throws = false;
            try
            {
                var official = new Official("Test Official", "-$OKF");
            }
            catch (Exception)
            {
                throws = true;
            }
            Assert.IsTrue(throws);
        }
    }
}
